﻿using Architecture.CrossCutting.Common;
using Architecture.CrossCutting.Common.Dependency;
using Architecture.CrossCutting.Common.Logging;
using Architecture.CrossCutting.LoggingEntities.Logger;
using Architecture.CrossCutting.Web;
using Architecture.CrossCutting.Web.Tracing.Model;
using Architecture.CrossCutting.Web.WCF;
using Architecture.CrossCutting.Web.WebApi;
using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Http.Tracing;
using System.Web.Routing;

namespace Architecture.Presentation.WebApiServices2
{
    public class WebApiApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            var container = new UnityContainer();
            //container.RegisterType<IGenericLogger<WcfLogDetail>, Logger<WcfLogDetail>>(new HierarchicalLifetimeManager());
            container.RegisterType<IGenericLogger<WcfClientLog>, WcfClientLogger>(new HierarchicalLifetimeManager());
            container.RegisterType<IGenericLogger<WebApiLog>, WebApiLogger>(new HierarchicalLifetimeManager());
            //container.RegisterType<IGenericLogger<WebApiLog>, StandardWebApiLogger>(new HierarchicalLifetimeManager());

            container.RegisterType<IExecutionContext, WebExecutionContext>();

            CustomContext.Current.DependencyResolver = new UnityResolver(container);

            LoggingConfig.Register();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            GlobalConfiguration.Configure(UnityConfig.Register);

        }
    }
}
